package com.example.demoboot.controller;

import com.example.demoboot.model.SubClassSelectVo;
import com.example.demoboot.service.POIService;
import com.example.demoboot.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
public class POIController {
    @Autowired
    private POIService poiService;
    @PostMapping("importFile")
    public ResultVo importFile(MultipartFile file)throws Exception{
      return   poiService.importFile(file);
    }
    @GetMapping("exportFile")
    public ResultVo exportFile(String name, String code, Boolean status, HttpServletResponse response)throws Exception{
        SubClassSelectVo subClassSelectVo = new SubClassSelectVo();
        subClassSelectVo.setCode(code);
        subClassSelectVo.setName(name);
        subClassSelectVo.setStatus(status);
      return   poiService.exportFile(subClassSelectVo,response);
    }
}
